package com.example.controller;

import com.example.pojo.Result;
import com.example.pojo.UpdatePasswordInfo;
import com.example.service.UpdatePasswordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class UpdatePasswordController {

    @Autowired
    private UpdatePasswordService updatePasswordService;

    /**
     * 修改用户密码
     */
    @PutMapping ("/updatePassword")
    public Result updatePassword(@RequestBody UpdatePasswordInfo updatePasswordInfo) throws Exception {
        log.info("修改密码, username: {}, oldPassword: {}", updatePasswordInfo.getUsername(), updatePasswordInfo.getOldPassword());
        updatePasswordService.updatePassword(updatePasswordInfo);

        return Result.success();
    }
}
